package com.hzxy.yiyid.web.module.repository.entity;

import com.hzxy.yiyid.web.common.constants.YiyidConstants;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName DoctorPenaltyDo
 * @Description TOOD
 * @Author RAICOM2023
 * @Date 2023/3/6 10:45
 * @Version 1.0
 **/
@Data
@Entity
@Table(name = "doctor_penalty")
public class DoctorPenaltyDo implements Serializable {

    private static final long serialVersionUID = -3205709525249974254L;
    @Id
    @Column(name = "doctor_penalty_id")
    @GenericGenerator(
            name = "generator_doctor_penalty",
            strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
            parameters = {
                    @Parameter(name = "sequence_name", value = "s_doctor_penalty"),
                    @Parameter(name = "initial_value", value = "1"),
                    @Parameter(name = "increment_size", value = "1")
            }
    )
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "generator_doctor_penalty")
    private Long doctorPenaltyId;

    /**
     * 处罚对象
     */
    @Column(name = "ys_cfdx")
    private String ysCfdx;

    /**
     * 处罚决定书文号
     */
    @Column(name = "ys_cfjds")
    private String ysCfjds;

    /**
     * 处罚种类
     */
    @Column(name = "ys_cfzl")
    private String ysCfzl;

    /**
     * 处罚事由
     */
    @Column(name = "ys_cfsy")
    private String ysCfsy;

    /**
     * 处罚决定
     */
    @Column(name = "ys_cfnr")
    private String ysCfnr;

    // 处罚日期
    @Column(name = "ys_cfrq")
    @DateTimeFormat(pattern = YiyidConstants.DATE_FORMAT_DEFAULT_VIEW2)
    private Date ysCfrq;

    /**
     * 结案情况
     */
    @Column(name = "ys_cfzxqk")
    private String ysCfzxqk;

    /**
     * 处罚机关
     */
    @Column(name = "ys_cfjg")
    private String ysCfjg;

    /**
     * 唯一主键
     */
    @Column(name = "ys_id")
    private String ysId;

    /**
     * 保存时间
     */
    @Column(name = "save_time")
    @DateTimeFormat(pattern = YiyidConstants.DATE_FORMAT_DEFAULT_VIEW)
    private Date saveTime = new Date();

    /**
     * 修改时间
     */
    @Column(name = "update_time")
    @DateTimeFormat(pattern = YiyidConstants.DATE_FORMAT_DEFAULT_VIEW)
    private Date updateTime;

    public DoctorPenaltyDo(){

    }

    public DoctorPenaltyDo(String ysCfdx, String ysCfjds, String ysCfzl, String ysCfsy, String ysCfnr, String ysCfrq
            ,String ysCfzxqk, String ysCfjg, String ysId){
        this.ysCfdx = ysCfdx;
        this.ysCfjds = ysCfjds;
        this.ysCfzl = ysCfzl;
        this.ysCfsy = ysCfsy;
        this.ysCfnr = ysCfnr;
        this.ysCfzxqk = ysCfzxqk;
        this.ysCfjg = ysCfjg;
        this.ysId = ysId;
        this.saveTime = new Date();
        try{
            SimpleDateFormat format = new SimpleDateFormat(YiyidConstants.DATE_FORMAT_DEFAULT_VIEW2);
            this.ysCfrq = format.parse(ysCfrq);
        }catch (Exception e){
            // do nohing
        }
    }

}
